package Person.models;

import Person.Base.BaseRangeException;
import Person.Base.State;

/**
 * 宠物创建的基类
 * @author Void
 * @version 1.0
 * @since 2021/10/20
 */
public abstract class BaseClass {
    protected int Type;
    private String Name;
    private int Sex ;
    private int Healthy;
    private int intimacy;

    /**
     * @return 返回名称
     */
    public String getName() {
        return this.Name;
    }

    /**
     * @param name:输入的名称
     */
    public void setName(String name) {
        this.Name = name;
    }

    /**
     * @return 返回健康值
     */
    public int getHealthy() {
        return this.Healthy;
    }

    /**
     * @param healthy:输入的健康值
     */
    public void setHealthy(int healthy) throws BaseRangeException {
        if (healthy < 0) {
            throw new BaseRangeException(State.IntError);
        }else{
            this.Healthy = healthy;
        }
    }

    /**
     * @return 返回的亲密值
     */
    public int getIntimacy() {
        return this.intimacy;
    }

    /**
     * @param intimacy：输入的亲密值
     */
    public void setIntimacy(int intimacy) throws BaseRangeException {
        if (intimacy <0) {
            throw new BaseRangeException(State.IntError);
        }else{
            this.intimacy = intimacy;
        }
    }

    /**
     * @return 返回的性别
     */
    public String getSex(){
        if (this.Sex==0){
            return "雌";
        }else{
            return "雄";
        }
    }

    /**
     * @param sex 输入的性别值
     */
    public void setSex(int sex) throws BaseRangeException{
            this.Sex = sex;
    }

    /**
     * @return 返回的类型
     */
    protected abstract String getType();

    /**
     * @param type:输入产品类型
     */
    protected abstract void setType(int type) throws BaseRangeException;

    @Override
    public String toString() {
        return "{" +
                "Type=" + getType() +
                ", Name='" + getName() +
                ", Sex=" + getSex() +
                ", Healthy=" + getHealthy() +
                ", intimacy=" + getIntimacy() +
                '}';
    }
}
